// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_c;

import android.content.*;
import android.database.Cursor;
import android.text.TextUtils;
import com.nnee.p_pr.p_prov.k;

public class cls_d
{

    public cls_d()
    {
    }

    public static Cursor a(Context context, String s)
    {
        Object obj = null;
        if(context != null && !TextUtils.isEmpty(s))
        {
            String s1 = (new StringBuilder()).append("account = '").append(s).append("'").toString();
            obj = context.getContentResolver().query(k.b, a, s1, ((String []) (obj)), " timestamp ASC");
        }
        return ((Cursor) (obj));
    }

    public static void a(Context context, String s, String s1)
    {
        if(context != null && !TextUtils.isEmpty(s) && !TextUtils.isEmpty(s1))
        {
            ContentValues contentvalues = new ContentValues();
            contentvalues.put("account", s);
            contentvalues.put("content", s1);
            contentvalues.put("timestamp", Long.valueOf(System.currentTimeMillis()));
            context.getContentResolver().insert(k.b, contentvalues);
            b(context, s);
        }
    }

    public static Cursor b(Context context, String s, String s1)
    {
        Object obj = null;
        if(context != null && !TextUtils.isEmpty(s))
        {
            String s2 = (new StringBuilder()).append("account = '").append(s).append("'").append(" AND ").append("content").append(" like '%").append(s1).append("%'").toString();
            obj = context.getContentResolver().query(k.b, a, s2, ((String []) (obj)), " timestamp ASC");
        }
        return ((Cursor) (obj));
    }

    public static void b(Context context, String s)
    {
        Cursor cursor = a(context, s);
        if(cursor != null)
        {
            int i = 0;
            System.currentTimeMillis();
            int j = cursor.getCount();
            if(j > 50)
            {
                cursor.moveToFirst();
                long l;
                do
                {
                    i++;
                    l = cursor.getLong(2);
                } while(j + -50 > i);
                cursor.close();
                String s1 = (new StringBuilder()).append("_id in ( select _id from search where timestamp < ").append(l).append(")").toString();
                context.getContentResolver().delete(k.b, s1, null);
            } else
            {
                cursor.close();
            }
        }
    }

    static String a[];
    public static final int b = 0;
    public static final int c = 1;
    public static final int d = 2;
    public static final int e = 3;
    public static final int f = 4;

    static 
    {
        String as[] = new String[5];
        as[0] = "_id";
        as[1] = "account";
        as[2] = "timestamp";
        as[3] = "content";
        as[4] = "other";
        a = as;
    }
}
